<template>
  <el-card>
    <el-tabs>
      <div class="app-container">
        <h3>交易详情</h3>
        <el-form ref="form" :model="form" :rules="rules" label-width="150px">
          <!--<el-form-item label="代理商编号" prop="agentId">
            <el-input v-model="form.agentId" readonly/>
          </el-form-item>-->
          <el-form-item label="交易订单流水号" prop="orderId">
            <el-input v-model="form.orderId" readonly />
          </el-form-item>
          <el-form-item label="用户名称" prop="userName">
            <el-input v-model="form.userName" readonly />
          </el-form-item>
          <el-form-item label="用户手机号" prop="userPhone">
            <el-input v-model="form.userPhone" readonly />
          </el-form-item>
          <!--<el-form-item label="POS 小票参考号" prop="sysno">
            <el-input v-model="form.sysno" readonly />
          </el-form-item>
          <el-form-item label="商户名称" prop="merName">
            <el-input v-model="form.merName" readonly />
          </el-form-item>
          <el-form-item label="商户号" prop="merId">
            <el-input v-model="form.merId" readonly />
          </el-form-item>-->
          <el-form-item label="终端 sn 编号" prop="snCode">
            <el-input v-model="form.snCode" readonly />
          </el-form-item>
          <el-form-item label="交易金额(单位：元)" prop="transAmount">
            <el-input v-model="form.transAmount" readonly />
          </el-form-item>
          <el-form-item label="交易类型" prop="payType">
            <el-input v-model="form.payType" readonly />
          </el-form-item>
          <!--<el-form-item label="交易卡号" prop="cardNo">
            <el-input v-model="form.cardNo" readonly />
          </el-form-item>-->
          <el-form-item label="处理状态" prop="handleStaus">
            <el-input v-model="form.handleStaus" readonly />
          </el-form-item>
          <el-form-item label="处理结果" prop="handleResult">
            <el-input v-model="form.handleResult" readonly />
          </el-form-item>
        </el-form>
      </div>
      <div class="app-container">
        <h3>分润明细</h3>
        <el-table v-loading="loading" :data="shareList">
          <el-table-column label="数据主键" align="center" prop="id" />
          <el-table-column label="交易流水" align="center" prop="flowId" />
          <el-table-column label="分润人" align="center" prop="shareUserId" />
          <!--<el-table-column label="分润等额差比例" align="center" prop="shareDiff" />-->
          <el-table-column label="分润金额" align="center" prop="shareAmount" />
        </el-table>
        <el-form ref="form" :model="form" :rules="rules" label-width="150px">
          <el-form-item style="text-align: center;margin-left:-100px;margin-top:10px;">
            <el-button @click="close()">返回</el-button>
          </el-form-item>
        </el-form>
      </div>
    </el-tabs>
  </el-card>
</template>

<script>
import {getTTerminalTransFlowInfo, addTTerminalTransFlowInfo, updateTTerminalTransFlowInfo} from "@/api/pos/TTerminalTransFlowInfo";

export default {
  name: "TTerminalTransFlowInfo",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 导出遮罩层
      exportLoading: false,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 终端交易流水表格数据
      TTerminalTransFlowInfoList: [],
      shareList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        agentId: null,
        orderId: null,
        merName: null,
        merId: null,
        snCode: null,
        queryCreateTimeStr: null
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
      }
    };
  },
  created() {
    const id = this.$route.query && this.$route.query.id;
    getTTerminalTransFlowInfo(id).then(response => {
      this.form = response.data;
      this.shareList = response.data.shareList;
      this.loading = false;
      console.log(this.shareList);
      this.open = true;
      this.title = "查看交易详情";
    });
  },
  methods: {
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    /** 关闭按钮 */
    close() {
      this.$store.dispatch("tagsView/delView", this.$route);
      this.$router.push({path: "/merManage/TTerminalTransFlowInfo", query: {t: Date.now(), pageNum: this.$route.query.pageNum}})
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        agentId: null,
        machineType: null,
        orderId: null,
        sysno: null,
        merName: null,
        merId: null,
        snCode: null,
        transAmount: null,
        merSigeFee: null,
        extractionFee: null,
        settlementCycle: "0",
        payType: null,
        cardType: null,
        transCategory: null,
        cardNo: null,
        createTime: null,
        isValid: "0",
        handleStaus: null,
        handleResult: null
      };
      this.resetForm("form");
    },
    /** 查询详情按钮操作 */
    handleDetail(row) {
      const id = row.id || this.ids[0];
      //console.log("----------", id);
      this.$router.push({path: "/TTerminalTransFlowInfo/transManage/transDetail", query: {id: id, pageNum: this.queryParams.pageNum}});
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != null) {
            updateTTerminalTransFlowInfo(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addTTerminalTransFlowInfo(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    }
  }
};
</script>
